package com.ny.zmb.openapi.controller.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result implements Serializable {

    private Integer code;

    private Object data;

    private String msg;

    public static Result OK() {
        return Result.builder()
                .code(1)
                .msg("")
                .build();
    }

    public static Result ok() {
        return Result.builder()
                .code(1)
                .msg("")
                .build();
    }


    public static Result ok(Object data) {
        return Result.builder()
                .data(data)
                .code(1)
                .msg("")
                .build();
    }

    public static Result ok(String msg) {
        return Result.builder()
                .code(1)
                .msg(msg)
                .build();
    }

    public static Result ok(String msg, Object data) {
        return Result.builder()
                .data(data)
                .code(1)
                .msg(msg)
                .build();
    }

    public static Result ok(Object data, String msg) {
        return Result.builder()
                .data(data)
                .code(1)
                .msg(msg)
                .build();
    }

    public static Result fail() {
        return Result.builder()
                .code(0)
                .build();
    }

    public static Result fail(String msg) {
        return Result.builder()
                .code(0)
                .msg(msg)
                .build();
    }

    public static Result fail(Object data) {
        return Result.builder()
                .code(0)
                .data(data)
                .build();
    }

    public static Result fail(String msg, Object data) {
        return Result.builder()
                .code(0)
                .data(data)
                .msg(msg)
                .build();
    }

    public static Result fail(Object data, String msg) {
        return Result.builder()
                .code(0)
                .data(data)
                .msg(msg)
                .build();
    }
}
